package com.ys.bean.support;

import com.ys.exception.BeanDefinitionStoreException;
import com.ys.exception.NoSuchBeanDefinitionException;

/**
 * <p>@description: beanDefinition注册</p>
 *
 * @projectName: Spring-Mini
 * @className: BeanDefinitionRegistry
 * @author: yangshuang
 * @date: 2016/12/11 22:53
 */
public interface BeanDefinitionRegistry {
    /**
     * 注册bean相关定义
     * @param beanName
     * @param definition
     * @throws BeanDefinitionStoreException
     */
    void registerBeanDefinition(String beanName, BeanDefinition definition) throws BeanDefinitionStoreException;

    /**
     * 根据beanName获取bean定义
     * @param beanName
     * @return
     * @throws BeanDefinitionStoreException
     */
    BeanDefinition getBeanDefinitionByName(String beanName)throws BeanDefinitionStoreException;

    /**
     * 根据class类型获取bean定义
     * @param requiredType
     * @return
     * @throws NoSuchBeanDefinitionException
     */
    BeanDefinition getBeanDefinitionByClass(Class<?> requiredType)throws NoSuchBeanDefinitionException;

    /**
     * 判断bean是否已经在使用
     * @param beanName
     * @return
     */
    boolean isBeanNameInUse(String beanName);

    /**
     * 根据beanName查看bean定义是否已存在
     * @param beanName
     * @return
     */
    boolean containsBeanDefinition(String beanName);

    /**
     * 移除bean定义
     * @param beanName
     * @throws BeanDefinitionStoreException
     */
    void removeBeanDefinition(String beanName) throws BeanDefinitionStoreException;

    /**
     * Return the number of beans defined in the registry.
     * @return
     */
    int getBeanDefinitionCount();
}
